/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.itschapala.dsw2.estacionamiento.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.itschapala.dsw2.estacionamiento.modelo.Cobro;

/**
 *
 * @author Lindemann
 */
@Stateless
public class CobroDao extends AbstractDao<Cobro> implements CobroDaoLocal {
    @PersistenceContext(unitName = "estacionamiento-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CobroDao() {
        super(Cobro.class);
    }
    
     @Override
    public boolean findDuplicity(Cobro cobro) {
        //seleccionar consulta
        Query q= em.createNamedQuery("Cobro.findDuplicity");
        //poner parametros
        q.setParameter("fecha",cobro.getFecha());
         q.setParameter("idRegistro",cobro.getIdRegistro());
        //ejecutar
        return !q.getResultList().isEmpty();
    }
}
